
import request from '@/utils/request'
import { baseUrl } from '@/config/env';

//给角色分配权限时获取菜单
export const getMenuTreeNoTop = () => {
  return request({
    url: `${baseUrl}/rest/menu/listTree`,
    method: 'post'
  })
}

//添加修改菜单时选择父级菜单
export const getMenuTree = () => {
  return request({
    url: `${baseUrl}/rest/menu/selectMenuTreeList`,
    method: 'post'
  })
}

export const getList = (page, size, params) => {
  return request({
    url: baseUrl+'/rest/menu/listTree',
    method: 'post',
    params: {
      ...params,
      page,
      size,
    }
  })
}
export const remove = (menuId) => {
  return request({
    url: baseUrl+'/rest/menu/remove',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      menuId,
    }
  })
}

export const add = (row) => {
  return request({
    url: baseUrl+'/rest/menu/add',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: row
  })
}

export const update = (row) => {
  return request({
    url: baseUrl+'/rest/menu/edit',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: row
  })
}

export const getMenu = (menuId) => {
  return request({
    url: `${baseUrl}/rest/menu/view/${menuId}`,
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {}
  })
}


export const getMenuInfo = (menuId) =>{
  return request({
    url:`${baseUrl}/rest/menu/getMenuInfo`,
    method:'get',
    params:{
      menuId
    }
  })
}